﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MensUnoShop.Models.ViewModels.MarketViewModel>" %>
<%@ Import Namespace="MensUnoShop.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	men'suno SHOP
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="CONTENT2">
    <script type="text/javascript">
        $(document).ready(function () {
            $("a#mailtofriend").fancybox({ width: 510, height: 325, scrolling: 'no' });
            $("a#spec").fancybox();
            $("a#note").fancybox();
        });
    </script>
    <div class="CONTENT_LEFT">
        <ul>
            <%Html.RenderPartial("/Views/Shared/SearchBox.ascx"); %>
            <%Html.RenderPartial("/Views/Shared/ProductTitle.ascx",Model.LEFTTAG); %>
            <%Html.RenderPartial("/Views/Shared/HotSearch.ascx", Model.HOTKEYLIST); %>
            <%Html.RenderPartial("/Views/Shared/News.ascx",Model.NEWS); %>
        </ul>
    </div>
    <div class="CONTENT_RIGHT">
        <p class="FAST_LINK"><%=Html.GetNavLinkString(Model.NAVLIST)%> / <%if (Model.MARKET.GROUPTITLE != "N/A")
                                                                           { %>【<%:Model.MARKET.GROUPTITLE%>系列 】<%} %><%:Model.MARKET.TITLE %></p>
        <img src="<%:Model.PRODUCT.PICBIG %>" class="PRODUCT3_IMG" />
        <ul class="PRODUCT3_CONTENT">
            <%if (Model.MARKET.GROUPTITLE != "N/A")
              { %><li class="PRODUCT3_STYLE">【<%:Model.MARKET.GROUPTITLE%>系列】</li><%} %>
            <li class="PRODUCT3_STYLE"><%:Model.MARKET.TITLE %></li>
            <li class="PRODUCT3_SMALL">
                <%foreach(var p in Model.MARKET.PRODUCTLIST){%>
                    <a href="/market/n/<%:Model.MARKET.SN %>/<%:p.TITLETAGID %>/<%:Model.MARKET.TAGID %>"><img src="<%:p.PICSMALL %>" /></a>
                <%} %>
            </li>
            <li>
                <ul class="PRODUCR3_FORM"><li class="PRODUCT3_SIEZ_FORM"><a id="spec" href="/market/light/spec">Size Chart</a></li><li class="PRODUCT3_WASH"><a id="note" href="/market/light/note">Washing</a></li></ul>
            </li>
            <li>Size：<%=Html.GetSizeString(Model.PRODUCT.SPEC)%></li>
            <li class="PRODUCT_COMES_BT"> <%=Html.GetAmountString(Model.PRODUCT.SPEC)%></li>
            
            <li>Orig. price：NTD <%:Model.MARKET.SHOPPRICE%></li>
            <li>Price：<span class="PRODUCT3_PRICE">NTD <%:Model.MARKET.PRICE%></span></li>
            <li>
                <div class="PUTIN_SHOPPING_CART">
                    <p><a href="#" class="intoCart">加入購物車add to cart</a></p>
                    <ul class="PRODUCT3_SHARE">
                    <li class="PRODUCT3_SHARE_FACEBOOK"><a id="share_f" href="#">facebook</a></li>
                    <li class="PRODUCT3_SHARE_TWITTER"><a id="share_t" href="#">twitter</a></li>
                    <li class="PRODUCT3_SHARE_PLURK"><a id="share_p" href="#">plurk</a></li>
                    <li class="PRODUCT3_SHARE_SINA"><a id="share_s" href="#">sina</a></li>
                </ul>
                </div>
                <div class="PRODUCT3_CONTENT_RIGHT">
                <ul>

                <li class="PRODUCT3_BT_FAVORITE">
                        <input type="hidden" id="mguid_<%:Model.MARKET.MKGUID %>" name="mguid_<%:Model.MARKET.MKGUID %>" value="<%:Model.MEMBER!=null?Model.MEMBER.MGUID:Guid.Empty %>" />
                        <input type="hidden" id="mkguid_<%:Model.MARKET.MKGUID %>"  name="mkguid_<%:Model.MARKET.MKGUID %>" value="<%:Model.MARKET.MKGUID %>" />
                        <input type="hidden" id="productid_<%:Model.MARKET.MKGUID %>" name="productid_<%:Model.MARKET.MKGUID %>" value="<%:Model.PRODUCT.PDGUID %>" />
                        <input type="hidden" id="specid_<%:Model.MARKET.MKGUID %>" name="specid_<%:Model.MARKET.MKGUID %>" value="<%:Model.PRODUCT.SPEC.FirstOrDefault().SID %>" />    
                        <a href="javascript:addmyfavorite2('<%:Model.MARKET.MKGUID %>');">加入最愛</a>
                </li>
                <li class="PRODUCT3_BT_MAIL_TO"><a id="mailtofriend" name="mailtofriend" class="iframe" href="/market/mailtofriend/<%:Model.MARKET.SN %>">email to friend</a></li>
                </ul>
                </div>
            <br class="CLEAR" />
            </li>
            <li>
                <span class="FAVORITE_BT_CART"><a href="/market/c">檢視購物車</a></span>
            </li>
        </ul>
        <br class="CLEAR" />
        <ul id="pdintro">
             <li class="PRODUCT3_CONTENT_WORD"><%=((MensUnoShop.Models.NormalMarket)Model.MARKET).INTRODUCTION %></li>
            <%foreach (var mk in ((MensUnoShop.Models.NormalMarket)Model.MARKET).MARKETIMG)
              { %>
            <li class="PRODUCT3_CONTENT_IMGAE">
                <p>▼<%:mk.TITLE %></p>
                <div><img src="<%:mk.PATH %>" width="500"/></div>
            </li>
            <%} %>
            <li class="PRODUCT3_CONTENT_WORD"><%=((MensUnoShop.Models.NormalMarket)Model.MARKET).STANDARDS%></li>
           
            <li class="PRODUCT3_CONTENT_WORD"><%=((MensUnoShop.Models.NormalMarket)Model.MARKET).WASHNOTE%></li>
            <li class="PRODUCT3_CONTENT_WORD"><%=((MensUnoShop.Models.NormalMarket)Model.MARKET).SHOPPINGNOTE%></li>
        </ul>
        
        <img src="/Content/page_img/content2_bottom.gif" /></div>
    <br class="CLEAR" />
</div>
<script type="text/javascript">
$(document).ready(function () { $('.intoCart').click(addShoppingCart); shareArticle();});
function addShoppingCart() {
    <%if(Model.MEMBER==null){ %>
        alert('請先登入會員!!');
    <%}else if(Model.PRODUCT.SPEC.Sum(s=>s.STOCK)==0){ %>
            alert('賣場暫無庫存!!');
    <%}else{ %>
       if($("#specamt").val() > "0"){
           var jsonstring = {  "Mid": '<%:Model.MARKET.MKGUID %>',
                               "ProductId": '<%:Model.PRODUCT.PDGUID %>',
                               "SpecId": $("#speccode").val(),
                               "AmountId": $("#specamt").val(),
                               "Mktype":1
                             };
            $.ajax({
                type: "POST",
                traditional: true,
                url: "/api/stc",
                data: jsonstring,
                dataType: "json",
                success: function (data) {
                    if(data.code=="200"){
                        alert("已加入購物車!");
                    }
                    else
                        alert(data.response);
                } 
            });
        }
        else
            alert('請選擇數量');
        <%} %>
    }

    $(window).load(function(){
	    $('#pdintro img').each(function(i){
			$(this).removeAttr('width');
			$(this).removeAttr('height');
 
			//取得影像實際的長寬
			var imgW = $(this).width();
			var imgH = $(this).height();
 
			//計算縮放比例
			var w=500/imgW;
			var pre=1;
			if(w<1){
				pre=w;
			}else{
				pre=1;
			}
 
			if(pre!=1){
			    $(this).width(500);
			    $(this).height(imgH*pre);
                }
		});
    });
</script>

</asp:Content>
